import numpy as np

def smooth_solution1(x, y):
    return np.exp(-x-y**2)

def smooth_solution1_dx(x, y):
    # 偏导数关于 x
    return -np.exp(-x - y**2)

def smooth_solution1_dy(x, y):
    # 偏导数关于 y
    return -2 * y * np.exp(-x - y**2)

def smooth_solution2(x, y):
    return x * (x - 1) * y * (y - 1) * np.exp(-x**2 - y**2)

def smooth_solution2_dx(x, y):
    # ∂f/∂x = y*(y - 1)*(-2*x**2*(x - 1) + 2*x - 1)*exp(-x**2 - y**2)
    return y * (y - 1) * (-2 * x**2 * (x - 1) + 2 * x - 1) * np.exp(-x**2 - y**2)

def smooth_solution2_dy(x, y):
    # ∂f/∂y = x*(x - 1)*(-2*y**2*(y - 1) + 2*y - 1)*exp(-x**2 - y**2)
    return x * (x - 1) * (-2 * y**2 * (y - 1) + 2 * y - 1) * np.exp(-x**2 - y**2)

def f_smooth1(x, y):
    # -Laplace(u) = (1 - 4*y**2)*exp(-x - y**2)
    return (1 - 4 * y**2) * np.exp(-x - y**2)

def f_smooth2(x, y):
    # -Δu = 2*(x*(x - 1)*(2*y**2 - y*(y - 1)*(2*y**2 - 1) + 2*y*(y - 1) - 1) + y*(y - 1)*(2*x**2 - x*(x - 1)*(2*x**2 - 1) + 2*x*(x - 1) - 1))*exp(-x**2 - y**2)
    return 2 * (x * (x - 1) * (2 * y**2 - y * (y - 1) * (2 * y**2 - 1) + 2 * y * (y - 1) - 1) + y * (y - 1) * (2 * x**2 - x * (x - 1) * (2 * x**2 - 1) + 2 * x * (x - 1) - 1)) * np.exp(-x**2 - y**2)

def singular_solution(x, y):
    pass

def test_function(x, y):
    return x + y

def test_function_dx(x, y):
    return 1.0

def test_function_dy(x, y):
    return 1.0

def f_test(x, y):
    return 0.0